<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>新增反馈</title>
    <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="css/comments.css" media="all">
</head>
<body>
    <div class="maincontainer">
        <blockquote class="layui-elem-quote">
            新增反馈
            <button type="button" class="layui-btn layui-btn-sm" style="float: right;margin-top: -4px;" onclick="window.history.back();">返回</button>
        </blockquote>
        <form class="layui-form" action="" lay-filter="example">
            <div class="layui-form-item">
                <label class="layui-form-label">反馈标题：</label>
                <div class="layui-input-block">
                  <input type="text" name="title" autocomplete="off" placeholder="请输入反馈标题" class="layui-input" maxlength="20">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">反馈内容：</label>
                <div class="layui-input-block">
                    <textarea name="content" placeholder="请输入反馈内容" class="layui-textarea" maxlength="140"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1">确认</button>
                <button type="button" class="layui-btn layui-btn-primary" onclick="window.history.back()">取消</button>
              </div>
            </div>
        </form>
    </div>
<script type="text/javascript" src="plugins/layui/layui.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script>

    layui.config({
        base: 'plugins/layui/modules/',
    }).use(['http', 'form'], function() {
        var http = layui.http,
            form = layui.form;

        
        //监听提交
        form.on('submit(demo1)', function(data){
            // console.log(data.field)
            if($.trim(data.field.title) == "") {
                layer.msg('请输入反馈标题')
                return
            }
            if($.trim(data.field.content) == "") {
                layer.msg('请输入反馈内容')
                return
            }
            
            http.post('supplier/admin/feed/back/add',{
                title: data.field.title,
                content: data.field.content,
            },function(res){
                if(res.code == 200){
                    layer.msg('操作成功')
                    setTimeout(function(){
                        window.history.back()
                    },500)
                }else{
                    layer.msg(res.msg)
                }
            })
        });
    })
</script>
</body>